#! /bin/sh


# --- Example shell for vel2stiff
#     this code transforms velocities, density and Thomsen 
#     parameters into elastic stiffness coefficients for
#     isotropic or VTI medium.
#
#     Sverre Brandsberg-Dahl 1999

set -x

nx=91 fx=0.0 dx=50 
nz=51 fz=0.0 dz=50

vp0=1500  dvpdz=0.8     dvpdx=0.0  vplens=-800.0 
vs0=500   dvsdz=0.3     dvsdx=0.0  vslens=+100.0 
rho0=2.0 drhodz=0.0002 drhodx=0.0 rholens=-0.25 
tlens=600 dlens=1000
xlens=2250  ylens=0 zlens=1000 
eps=0.1 delta=-0.2 gamma=0.0

vpfile=vp_lens
vsfile=vs_lens
rhofile=rho_lens
epsfile=eps_lens
deltafile=delta_lens
gammafile=gamma_lens
c11_file=c11_lens 
c13_file=c13_lens 
c33_file=c33_lens 
c44_file=c44_lens 
c66_file=c66_lens


#   Make the P-wave velocity plane
makevel nx=$nx fx=$fx dx=$dx nz=$nz fz=$fz dz=$dz \
	v000=$vp0 dvdz=$dvpdz dvdx=$dvpdx \
	vlens=$vplens tlens=$tlens dlens=$dlens \
	xlens=$xlens ylens=$ylens zlens=$zlens >vp_lens

#   Make the S-wave velocity plane
makevel nx=$nx fx=$fx dx=$dx nz=$nz fz=$fz dz=$dz \
	v000=$vs0 dvdz=$dvsdz dvdx=$dvsdx \
	vlens=$vslens tlens=$tlens dlens=$dlens \
	xlens=$xlens ylens=$ylens zlens=$zlens >vs_lens

#   Make the density plane
makevel nx=$nx fx=$fx dx=$dx nz=$nz fz=$fz dz=$dz \
	v000=$rho0 dvdz=$drhodz dvdx=$drhodx \
	vlens=$rholens tlens=$tlens dlens=$dlens \
	xlens=$xlens ylens=$ylens zlens=$zlens >rho_lens

#   Make the epsilon plane
unif2 <layer.ascii nx=$nx fx=$fx dx=$dx nz=$nz fz=$fz dz=$dz \
	v00=$eps dvdz=0.0 dvdx=0.0 >eps_lens

#   Make the delta plane
unif2 <layer.ascii nx=$nx fx=$fx dx=$dx nz=$nz fz=$fz dz=$dz \
	v00=$delta dvdz=0.0 dvdx=0.0 >delta_lens

#   Make the gamma plane
unif2 <layer.ascii nx=$nx fx=$fx dx=$dx nz=$nz fz=$fz dz=$dz \
	v00=$gamma dvdz=0.0 dvdx=0.0 >gamma_lens


#   Transform into stiffness coefficients
vel2stiff vpfile=$vpfile vsfile=$vsfile rhofile=$rhofile  epsfile=$epsfile \
          deltafile=$deltafile gammafile=$gammafile nx=$nx nz=$nz  \
          c11_file=$c11_file c13_file=$c13_file c33_file=$c33_file \
          c44_file=$c44_file c66_file=$c66_file

exit 0
